// 初始化轮播
var mySwiper = new Swiper(".swiper", {
  // 如果需要分页器
  pagination: {
    el: ".swiper-pagination",
  },
});

// 关闭悬浮图标
function closeFloat(id) {
  $("#" + id).hide();
}

// 点击客服按钮时跳转到客服电话
function call(phone) {
  window.location.href = "tel:" + phone;
}
// 打开弹窗
function openPopup(id) {
  $("#" + id).show();
}
// 关闭客服弹窗
function closePopup(id) {
  $("#" + id).hide();
}

// 后退
function back() {
  window.history.back();
}

// toast
let timer = null;
function showToast(message) {
  const toast = document.getElementById("toast");
  if (timer) {
    clearTimeout(timer);
    toast.hidden = true;
    timer = null;
  }
  toast.textContent = message;
  toast.hidden = false;
  timer = setTimeout(() => {
    toast.hidden = true;
    timer = null;
  }, 3000);
}
